/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package colloque.servlets;

import colloque.Utilisateur;
import colloque.helpers.ColloqueHelper;
import colloque.helpers.SecurityHelper;
import colloque.helpers.UtilisateurHelper;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Administration extends HttpServlet {

    private static String VUE = "/jsp/administration.jsp";

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        SecurityHelper security = new SecurityHelper(request.getSession());
        if (security.isAuthenticated() == false) {
            response.sendRedirect("Connexion");
        } else {
            UtilisateurHelper utilisateurhelper = new UtilisateurHelper();
            ColloqueHelper colloquehelper = new ColloqueHelper();
            Utilisateur utilisateur = utilisateurhelper.getUtilisateurCourant(request);
            request.setAttribute("colloques", colloquehelper.getColloquesFromPresident(utilisateur.getUtilisateurid()));
            this.getServletContext().getRequestDispatcher(VUE).forward(request, response);
        }

    }
}